package com.sense.kukoo.biz_me.adapter.provider

import android.widget.TextView
import com.sense.kukoo.biz_me.R
import com.sense.kukoo.biz_me.adapter.SelectCountryAdapter
import com.sense.kukoo.common.repo.bean.AreaBean
import com.sense.kukoo.common.wiget.adapter.provider.MultiItemProvider
import com.sense.kukoo.common.wiget.adapter.viewholder.BaseViewHolder

class SelectCountryItemProvider(val listener: SelectCountryAdapter.OnSelectCountryListener) :
    MultiItemProvider<AreaBean>() {

    private val TAG: String = javaClass.simpleName

    override fun getItemType(): Int = AreaBean.TYPE_DEF

    override fun getItemLayoutId(): Int = R.layout.biz_me_item_select_country

    override fun onBindViewHolder(viewHolder: BaseViewHolder, bean: AreaBean) {
        viewHolder.getView(R.id.root).setOnClickListener {
            listener.onItemClick(bean, viewHolder.adapterPosition)
        }
        val tv_text = viewHolder.getView(R.id.tv_text) as TextView
        val tv_code = viewHolder.getView(R.id.tv_code) as TextView
        //
        tv_text.text = bean.text
        tv_code.text = bean.code
    }
}